package com.example.xm.controller;

import com.example.xm.Entity.Gwc;
import com.example.xm.mapper.GwcMapper;
import com.example.xm.servive.GwcServive;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/G")
public class GwcController {
    @Autowired
    GwcServive gwcServive;

    @Autowired
    private GwcMapper dao = null;

    /**显示*/
    @PostMapping("/spper")
    public List<Gwc> Students(@RequestBody Gwc gwc){
        System.out.println(gwcServive.getAllGwc(gwc));
        return gwcServive.getAllGwc(gwc);
    }

    /**删除*/
    @DeleteMapping("/{id}")
    public int del(@PathVariable String id){
        System.out.println("删除了："+id);
        return gwcServive.del(id);
    }

    /**批量删除*/
    @CrossOrigin
    @RequestMapping("/Btndelete")
    public boolean Btndelete(Integer ids[]){
        System.out.println("批量删除了："+ids.length + ids);
//        for(Integer id : ids){
//            System.out.println(id);
//        }
        return dao.Btndelete(ids);
    }

    /**修改*/
    @PutMapping("/gwc")
    public int UpdateGwc(@RequestBody Gwc gwc){
        System.out.println("修改了：" + gwc);
        return gwcServive.UpdateGwc(gwc);
    }

    /**根据id来获取订单信息*/
    @GetMapping("/{id}")
    public Gwc getDd(@PathVariable String id){
        System.out.println(gwcServive.getDd(id));
        return gwcServive.getDd(id);
    }
}
